home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 076-100 / disk_087 / dropshadow / hooks.asm < prev    next >
Assembly Source File  |  1992-05-06  |  1KB  |  76 lines

  1. ; hooks.asm -- intervene (layers) library vectors
  2. ;    :ts=8
  3.  
  4.  
  5. ; this program copyright 1987, james mackraz.  may not be distributed
  6. ; for profit.  copies of the source may be made for not-for-profit
  7. ; distribution, but must include this notice.
  8. ;
  9. ; james mackraz, 4021 Second Street, Palo Alto, CA, 94306
  10.  
  11.     include 'exec/types.i'
  12.  
  13.  STRUCTURE    HK,0
  14.      LONG    HK_SYSFUNC
  15.     LONG    HK_MYFUNC
  16.     LONG    HK_ENTRY
  17.     WORD    HK_TEST
  18.     LONG    HK_LVO
  19.     LABEL    HK_SIZE
  20.  
  21.     MACRO    UNIQUEHOOK
  22.     public    _entry%1
  23. _entry%1:
  24.     movem.l    regboys,-(sp)
  25.     jsr    _geta4
  26.     ; address of hook struct serves as unique id
  27.     lea    _myhooks + (%1 * HK_SIZE),a3
  28.     jsr    commonhook
  29.     movem.l    (sp)+,regboys
  30.     rts
  31.     ENDM
  32.  
  33. regboys    reg    d1/d2/d3/d5/a0/a1/a2/a3/a4/a5/a6
  34.  
  35.     ; uses registers that specific system functions
  36.     ; do not use, and will preserve.
  37.     ;    d3 --    aztec may trash
  38.     ;    d5 --    used in test
  39.     ;    a3 --    hook table entry
  40.     ;    a4 --    aztec context
  41.     ;    a5 --    called through
  42.     ;    a6 --    aztec may trash
  43.  
  44.     dseg
  45.     public    _myhooks
  46.  
  47.     cseg
  48.     public    _geta4
  49.  
  50.     ;------    unique entry points for each layer vector stolen
  51.     UNIQUEHOOK 0
  52.     UNIQUEHOOK 1
  53.     UNIQUEHOOK 2
  54.     UNIQUEHOOK 3
  55.     UNIQUEHOOK 4
  56.     UNIQUEHOOK 5
  57.     UNIQUEHOOK 6
  58.  
  59. commonhook:
  60.  
  61.     ; ***    test condition (two versions)
  62.     move.l    HK_SYSFUNC(a3),a5
  63.  
  64.     jsr    (a5)
  65.  
  66.     ; ***    call conditionally, based on test
  67.     ;------    save/pass myfunc the sysfunc return value
  68.     move.l    d0,-(sp)        
  69.     move.l    HK_MYFUNC(a3),a5
  70.     jsr    (a5)
  71.  
  72.     move.l    (sp)+,d0
  73.     rts
  74.  
  75.     end
  76.